<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
</head>

<body>
  <div id="app">
    <!-- 可以直接修改 -->
    <button @click = "obj.name = '666' ">点击修改对象</button>

    <!-- 不能直接添加 Vue监听不到对象中的添加删除 -->
    <button @click = "add">点击添加</button>

    <!-- 不能直接删除 Vue监听不到对象中的添加删除 -->
    <button @click = "de">点击删除</button>

    <!-- 列表渲染对象 -->
    <ul>
      <li v-for = "item in obj">{{item}}</li>
    </ul>

  </div>
  <script>
    Vue.config.productionTip = false;
    
    const vm = new Vue({
      el: "#app",
      data() {
        return {
          obj:{
            name: "laowang",
            age: 18,
            addres: "云南"
          }
        }
      },
      methods:{
        add(){
          //不能直接添加
          // Vue.set(this.obj , Date.now() , "大理")
          vm.$set(this.obj , Date.now() , "拉萨")
        },
        de(){
          Vue.delete(this.obj , "name")
        }
      }
    })
  </script>
</body>

</html>